class Solution {
public:
    bool kLengthApart(vector<int>& nums, int k) {
        int pre=-1;
        for(int u=0; u<nums.size(); u++)
            if(nums[u]==1) {
                if(pre==-1) {pre=u; continue;}
                if(u-pre<=k) return false;
                pre=u;
            }
        return true;
    }
};